//
//  ILPlayerProtocol.h
//  Pods
//
//  Created by 方耀 on 2022/10/24.
//

#ifndef ILPlayerProtocol_h
#define ILPlayerProtocol_h

#import <Foundation/Foundation.h>
#import "ILVideoEnum.h"
#import <FFmpegSDK/FfmpegSDK.h>
#import "ILVideoViewProtocol.h"
#import "ILIotAudioParams.h"

/**
 * \brief 日志级别
 */
typedef NS_ENUM(NSUInteger, ILPlayerLogLevel){
    /** debug */
    ILPlayerLogDebug = 1,
    /** info */
    ILPlayerLogInfo = 2,
    /** warning */
    ILPlayerLogWarning = 3,
    /** error */
    ILPlayerLogError = 4
};

@protocol ILPlayerProtocol <NSObject>

//添加代理
@property (nonatomic, weak) id<ILVideoViewProtocol> delegate;
@property(nonatomic, assign) ILPlayerType playerType;//播放器类型
//设置通话模式
@property(nonatomic, assign) BOOL useSpeakAudioModeLive;
//设备iotid
@property(nonatomic, copy) NSString *did;
//是否静音
@property(nonatomic, assign, getter=isMute, setter=setMute:) BOOL mute;
//倍速
@property(nonatomic, assign, getter=getPlayerSpeed, setter=setPlayerSpeed:) ILPlayerSpeed playerSpeed;
//缩放比
@property(nonatomic, assign, setter=setScaleRatio:) CGFloat scaleRatio;
//--- 后续协议返回
//码率
@property(nonatomic, assign, readonly, getter=getBitRate) NSInteger bitRate;
  // 播放器当前状态
@property(nonatomic, assign, readonly, getter=getPlayerState) ILPlayerState playerState;
// 当前直播模式(仅适用直播)
@property(nonatomic, assign, readonly, getter=getConnetType) ILPlayerConnectType connetType;

//初始化
- (instancetype)initWithILPlayerType:(ILPlayerType)playerType;
//设置数据源
- (BOOL)setNewDataSource:(NSDictionary *)dataSource;
//开始录像
- (BOOL)startRecord:(NSString *)filePath;
//停止录像
- (BOOL)stopRecord;

//截图 、同步
- (UIImage *)videoSnapshot;
//截图、 一步
- (UIImage*)snapshotPicture:(void(^)(UIImage* image))finish;

//录播暂停播放
- (void)pause;
//录播恢复播放
- (void)restore;

////仅录播、实时流 设置畸变校准，enable=false时 x，y，r无效
//- (void)setLensCorrect:(BOOL)enable x:(CGFloat)x y:(CGFloat)y r:(CGFloat)r;
////设置屏幕水平分割模式  renderSplitMode: 参考 ffmpegSDk 下  RenderSplitMode 枚举
//- (void)setSplitHorizontalMode:(NSInteger)mode;

//仅实时流
- (void)voiceChange:(int)type;  //变声

//开始播放
- (void)start;
//停止播放
- (void)stop;
//激活声音
- (void)activePlayer;
//设置静音
- (void)setMute:(BOOL)isMute;

- (BOOL)isMute;

- (NSInteger)getCurrentPosition;

- (NSInteger)getRecordMP4Duration;

//获取播放器渲染视图 ，考虑后续去除
//23/6/13 去掉,使用 setDisplay代替.
//- (ILEAGLView *)getEaglView;

//设置播放器显示的视图View
- (void *)setDisplay:(UIView * )uiView;

//切换渲染模式，目前使用 {@link setLensCorrect }
//- (NSInteger)enhanceRender:(IMIEnhanceRenderAlgoType)algoType;

//播放器销毁，不在使用后在调用此函数进行释放
- (void)destroy;

//获取播放器视图控制器 去除
//- (UIViewController *)getPlayerVC;

@optional
//开启对讲
- (void)startSpeak;
//关闭对讲
- (void)stopSpeak;
//设置录播进度
- (BOOL)seekTo:(NSTimeInterval)seconds;
//设置录播倍速
- (void)setPlayerSpeed:(ILPlayerSpeed)playerSpeed;

//设置直播播放源
- (BOOL)setDataSourceFromLive:(NSString *)iotId;

/// 设置直播播放源,如果没有传物模型参数,就获取本地缓存的物模型参数
/// @param iotId iotId
/// @param propertiesParams 物模型参数
- (BOOL)setDataSourceFromLive:(NSString *)iotId propertiesParams:(NSDictionary *)propertiesParams;
- (BOOL)setDataSourceLiveWithAudioParam:(NSString *)iotId audioParam:(ILAudioParams)audioParam;

//设置云存、报警事件播放源
- (BOOL)setDataSourceFromHls:(NSString *)iotId fileName:(NSString *)fileName seekTime:(NSTimeInterval)seekTime;

//设置回看播放源
- (BOOL)setDataSourceFromVod:(NSString *)iotId startTime:(NSInteger)startTime endTime:(NSInteger)endTime seekTime:(NSInteger)seekTime;

/// 设置日志等级,发布正式版本请不要打开debug
- (void)setLogLevel:(ILPlayerLogLevel)logLevel;


@end

#endif /* ILPlayerProtocol_h */

